

cc.Class({
	extends: cc.Component,

	properties: {
		playerNode: {
			default: null,
			type: cc.Node,
		},
		backgroundMap: cc.Node,
	},

	// LIFE-CYCLE CALLBACKS:

	// onLoad () {},

	start() {
		this.playerPosition = this.playerNode.position;
	},

	// update (dt) {},

	lateUpdate(dt) {
		this.playerPosition = this.playerNode.position;
		if (this.node.position.sub(this.playerPosition).mag() > this.backgroundMap.height / 3) {
			this.node.setPosition(this.playerPosition);
		}
	},
});
